package com.nidu.demo.file;

import com.alibaba.cola.dto.MultiResponse;
import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.nidu.demo.file.api.SysFileConfigService;
import com.nidu.demo.file.dto.*;
import com.nidu.demo.file.executor.command.FileConfigAddCmdExe;
import com.nidu.demo.file.executor.command.FileConfigDeleteCmdExe;
import com.nidu.demo.file.executor.command.FileConfigUpdateCmdExe;
import com.nidu.demo.file.executor.query.FileConfigListQryExe;
import com.nidu.demo.file.executor.query.FileConfigPageQryExe;
import com.nidu.demo.file.executor.query.FileConfigSingleQryExe;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Set;

/**
 * 文件配置服务实现类
 *
 * @author auto
 */
@Service
@RequiredArgsConstructor
public class SysFileConfigServiceImpl implements SysFileConfigService {

    private final FileConfigAddCmdExe addCmdExe;
    private final FileConfigUpdateCmdExe updateCmdExe;
    private final FileConfigDeleteCmdExe deleteCmdExe;
    private final FileConfigSingleQryExe singleQryExe;
    private final FileConfigListQryExe listQryExe;
    private final FileConfigPageQryExe pageQryExe;

    @Override
    public SingleResponse<FileConfigCO> add(FileConfigAddCmd cmd) {
        return addCmdExe.execute(cmd);
    }

    @Override
    public SingleResponse<FileConfigCO> update(FileConfigUpdateCmd cmd) {
        return updateCmdExe.execute(cmd);
    }

    @Override
    public Response delete(Long id) {
        deleteCmdExe.execute(id);
        return Response.buildSuccess();
    }

    @Override
    public Response delete(Set<Long> ids) {
        deleteCmdExe.execute(ids);
        return Response.buildSuccess();
    }

    @Override
    public SingleResponse<FileConfigCO> getById(Long id) {
        return singleQryExe.execute(id);
    }

    @Override
    public MultiResponse<FileConfigCO> list(FileConfigListQry qry) {
        return listQryExe.execute(qry);
    }

    @Override
    public PageResponse<FileConfigCO> page(FileConfigPageQry qry) {
        return pageQryExe.execute(qry);
    }

    @Override
    public Response updateMaster(Long id) {
        return updateCmdExe.updateMaster(id);
    }
}
